package com.yyg.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
//全局配置，配置跨域请求
@Configuration//全局配置类
public class WebConfig extends WebMvcConfigurerAdapter {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")//运行跨域的东西，域访问路径
                .allowedOrigins("Http://localhost:8081","null")//运行跨域的地址，请求来源
                .allowedMethods("GET","POST","PUT","OPTIONS","DELETE")//允许跨域的方法
                .allowCredentials(true)
                .maxAge(3600);//相应最大时间
    }
}
